Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#include <ctype.h>
void optionTray();
void secondOptionTray();
void addition()
{printf("\nEnter nos. to add separated by space_ || press Enter ┘ for solution \n\n");
int input=0; int ans=0; char c='\0';
while(c!='\n'){
scanf("%d", &input);
ans+= input;
c=getchar();
}
void subtraction ()
{
int first, second; int ans = 0;
printf ("\nEnter the first number : ");
scanf ("%d", &first);
printf ("Enter the second number : ");
scanf ("%d", &second);
ans=first - second;
printf ("\n = %d", ans);
secondOptionTray();
}
void multiplication ()
{
printf("\nEnter nos. to multiply separated by space_ || press Enter ┘ for solution \n\n");
int input=0; int ans=1; char c='\0';
while(c!='\n'){
scanf("%d", &input);
ans*= input;
c=getchar();
}
void division ()
{
int dend, isor=0;char c='\0';
printf ("\nEnter the Dividend: ");
scanf ("%d", &dend);
printf ("Enter the Divisor: ");
scanf ("%d", &isor);
int ans = dend / isor;
printf ("\nQuotient is = %d", ans);
printf("\nRemainder is");
printf(" = %d", (dend%isor));
secondOptionTray();
}
void power ()
{
double base, exponent, ans;
printf ("\nEnter the Base: ");
scanf ("%lf", &base);
printf ("Enter the Exponent(Power): ");
scanf ("%lf", &exponent);
ans = pow (base, exponent);
printf ("\n = %lf", ans);
secondOptionTray();
}
void sqroot()
{
}
void cbroot(){
double input;
printf("\nEnter no. for Cube Root: ");
scanf("%lf", &input);
printf("\n = %lf", cbrt(input));
secondOptionTray();
}
void factorial ()
{
int input, fact = 1;
printf ("\nEnter a number to find factorial : ");
scanf ("%d", &input);
if (input < 0)
printf ("\nPlease enter a positive number..");
if (input == 0)
printf("\n = 1");
else{
for (int x = 1; x <= input; x++){
fact = fact * x;}
}
//**************************************
int main ()
{
char choice='\0';
printf ("\n\t\t\t\tWelcome to C calculator\n\n");
optionTray();
while (1>0)
{
}
void secondOptionTray()
{
printf ("\n\n## Press 's' to stop ##");
printf("\n\n## Press 'm' for Full Option Menu ## ");
}
void optionTray()
{
secondOptionTray();
printf ("\n\n\nEnter '+' or '1' for Addition");
printf ("\t\t\t\tEnter '-' or '2; for Subtraction");
printf ("\nEnter '*' or '3' for Multiplication");
printf ("\t\t\tEnter '/' or '4' for Division");
printf ("\nEnter '^' or '5' for Power");
printf ("\t\t\t\tEnter '|' or '6' for Square Root");
printf ("\nEnter '~' or '7' for Cube Root");
printf ("\t\t\t\tEnter '!' or '8' for Factorial \n\n");
printf ("\n\n\n\nEnter the option you wish to perform — ");
}